<html lang="en">

<head>

    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>2025年跨年拆盲盒</title>
    <style>
        body {
            background-image: url('https://d31zlh4on95l9h.cloudfront.net/images/5iujax01000d6m4i0krgq8e1zcnz02kn.png'), url('https://d31zlh4on95l9h.cloudfront.net/images/5iujau01000d6m4fkuwgqrs23fqd7fzu.png');
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
        }

        .title {
            text-align: center;
        }

        .box {
            background-image: url('https://d31zlh4on95l9h.cloudfront.net/images/5iujb101000d6m4h3w51tp821kdld3qs.png');
            background-position: center;
            background-size: cover;
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            align-items: center;
            width: 410px;
            height: 630px;
            margin: 100px auto;
        }

        .choujiang {
            margin-top: 120px;
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            width: 400px;
            height: 350px;

        }

        .item {
            position: relative;
            margin: 5px;
            width: 100px;
            height: 100px;

        }

        .style1,
        .style2 {
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            right: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            border-radius: 5px;
            text-align: center;
            transition: transform.4s
        }

        .style1 {
            background-image: url('https://d31zlh4on95l9h.cloudfront.net/images/5iujax01000d6m4iki8lzei1zdmha826.png');
            background-position: center;
            background-size: cover;
        }

        .style2 {
            color: #ff8800;
            border: 1px solid #ff8800;
            padding: 0 10px;
            transform: scaleX(0);
            background-color: #ffe6c9;
        }

        .hide {
            transform: scaleX(0);
        }

        .show {
            transform: scaleX(1);
        }

        .show-result {
            transform: scaleX(1);
            opacity: 0.5;
        }
                /* 新增的用于设置奖品文字字号的类 */
      .prize-text {
            font-size: 20px; /* 可以修改为你想要的字号大小 */
        }
    </style>
    <style>
    </style>
</head>

<body>
    <!-- <div class="title">可抽奖<label id="count">1</label>次</div> -->

    <div class="box">
    <div class="choujiang"><label id="count"></label>

            <div class="item" onclick="fp(this)">
                <div class="style1"></div>
                <div class="style2"></div>
            </div>
            <div class="item" onclick="fp(this)">
                <div class="style1"></div>
                <div class="style2"></div>
            </div>
            <div class="item" onclick="fp(this)">
                <div class="style1"></div>
                <div class="style2"></div>
            </div>
            <div class="item" onclick="fp(this)">
                <div class="style1"></div>
                <div class="style2"></div>
            </div>
            <div class="item" onclick="fp(this)">
                <div class="style1"></div>
                <div class="style2"></div>
            </div>
            <div class="item" onclick="fp(this)">
                <div class="style1"></div>
                <div class="style2"></div>
            </div>
            <div class="item" onclick="fp(this)">
                <div class="style1"></div>
                <div class="style2"></div>
            </div>
            <div class="item" onclick="fp(this)">
                <div class="style1"></div>
                <div class="style2"></div>
            </div>
            <div class="item" onclick="fp(this)">
                <div class="style1"></div>
                <div class="style2"></div>
        </div>
    </div>
</div>

    <script>
        // 奖品列表
        const list = [
            { id: 1, name: '<b>69天<br>AI雷达<b>', is: true },
            { id: 2, name: '<b>69天<br>AI雷达<b>', is: true },
            { id: 3, name: '<b>69天<br>AI雷达<b>', is: true },
            { id: 4, name: '<b>69天<br>AI雷达<b>' },
            { id: 5, name: '<b>69天<br>AI雷达<b>' },
            { id: 6, name: '<b>69天<br>AI雷达<b>' },
            { id: 7, name: '<b>69天<br>AI雷达<b>' },
            { id: 8, name: '<b>69天<br>AI雷达<b>' },
            { id: 9, name: '<b>69天<br>AI雷达<b>' }
        ].sort(v => Math.random() - 0.5);
        // 中奖项
        const isArr = list.filter(v => v.is);
        // 非中奖项
        const noArr = list.filter(v => !v.is);
        // 抽奖次数
        let count = 1; // 修改为只能抽奖1次
        const box = document.querySelector('.choujiang');
        const countEL = document.querySelector('#count');
        countEL.innerHTML = count;
        box.innerHTML = list.map(v => {
            return `<div class="item" onclick="fp(this)">
                <div class="style1"></div>
                <div class="style2"></div>
            </div>`;
        }).join('');

        // 翻牌抽奖
        const fp = (me) => {
            if (count === 0) {
                return;
            }
            me.querySelector('.style1').classList.add('hide');
            // 抽奖动画
            setTimeout(() => {
                const item = isArr.pop();
                const style2 = me.querySelector('.style2');
                if (item.is) { // 只有抽到奖了才显示对应奖项并翻转
                    style2.innerHTML = `<span class="prize-text">${item.name}</span>`;
                    style2.classList.add('show');
                }
            }, 400);
            count--;
            countEL.innerHTML = count;
            // 抽奖次数用完后不再进行后续多余的展示全部奖项等操作
            if (count === 0) {
                return;
            }
        }
    </script>
</body>

</html>